<#include "/common/common.ftl" encoding="UTF-8">
	<link href="${staticUrl}/css/form.css" type="text/css" rel="stylesheet" />
	<link href="${staticUrl}/js/validate/jquery.validate.css" type="text/css" rel="stylesheet" />
	<script src="${staticUrl}/js/validate/jquery.validate.js" type="text/javascript"></script>
	<script src="${staticUrl}/js/validate/messages_cn.js" type="text/javascript"></script>
	<script src="${staticUrl}/common/fckeditor/editor/js/fckeditorcode_ie.js" type="text/javascript"></script>
	<script src="${staticUrl}/common/fckeditor/fckconfig.js" type="text/javascript"></script>
	<script src="${staticUrl}/common/fckeditor/editor/dialog/common/fck_dialog_common.js" type="text/javascript"></script>
	<script src="${staticUrl}/common/fckeditor/cj.js" type="text/javascript"></script>
	<#assign action="channel">
	<script>
		var treeUrl = "${request.contextPath}/security/${action}!getTreeXml.action?rootId=1";
		var whichTemplate = 'template';
		$(document).ready(function(){
			//为inputForm注册validate函数
			$("#inputForm").validate();
			$("#parentName").click(function(e){
				previewShow(e);
			});
			$("#templateName").click(function(e){
				previewShowList();
				ajaxShowTemplates('channel');
				whichTemplate = 'template';
			});
			$("#pertainTemplateName").click(function(e){
				previewShowList();
				ajaxShowTemplates('pertain');
				whichTemplate = 'pertain';
			});
			$("#contentTemplateName").click(function(e){
				previewShowList();
				ajaxShowTemplates('article');
				whichTemplate = 'article';
			});
		});
		function ajaxShowTemplates(type){
				$.ajax({url: '${request.contextPath}/security/template!findByType.action?templateType=' + type + '&' + new Date().getTime(),
						type: 'GET',dataType: 'html',
						timeout: 30000,
						error: function(){alert('获取模板出错！超时！');    },    
						success: function (data){		
														$("#list_div_table").html(data);
												}
					});
			$("#preview_list").show();			
		}
		function listDivClick(id,name){
			if(whichTemplate == 'template'){
				$('#templateId').val(id);
				$('#templateName').val(name);
			}
			if(whichTemplate == 'pertain'){
				$('#pertainTemplateId').val(id);
				$('#pertainTemplateName').val(name);
			}
			if(whichTemplate == 'article'){
				$('#contentTemplateId').val(id);
				$('#contentTemplateName').val(name);
			}
			$("#preview_list").hide();			
		}
		function showDetail(id,title){
			$("#parentId").val(id);
			$("#parentName").val(title);
			$("#preview").hide();
		}
	</script>
</head>
<body style="padding-left: 10px ;">
<#include "/common/tree_div.ftl" encoding="UTF-8">
<#include "/common/list_div.ftl" encoding="UTF-8">
<div class="title"><#if id?exists>修改<#else>创建</#if>栏目</div>
<div id="inputContent" class="content">
<form id="inputForm" action="${action}!save.action" method="post">
<input type="hidden" name="id" value="${(id)?if_exists}" />
<table class="content">
	<tr>
		<@ftlMacro.inputText name="code" descript="栏目代码" textShow="${code?if_exists}" cssStyle="required"/>
	</tr>
	<tr>
		<@ftlMacro.inputText name="name" descript="栏目名称" textShow="${name?if_exists}" cssStyle="required"/>
	</tr>
	<tr>
		<@ftlMacro.inputText name="orderNum" descript="顺序" textShow="${orderNum?if_exists}" cssStyle="number required"/>
	</tr>
	<tr>
		<@ftlMacro.inputText name="articleNum" descript="每页文章条数" textShow="${articleNum?if_exists}" cssStyle="number"/>
	</tr>
	<tr>
		<td class="textLabel">上级栏目</td>
		<td>
			<input type="hidden" name='parent.id' id="parentId" value="${(parent.id)?if_exists}"/>
			<input type="text" class='divshow' name="parent.name" id="parentName" size="40" value="${(parent.name)?if_exists}" class="required"/>		
		</td>
	</tr>
	<tr>
		<td class="textLabel">栏目模板</td>
		<td>
			<input type="hidden" name='template.id' id="templateId" value="${(template.id)?if_exists}"/>
			<input type="text" class='divshow' name="template.name" id="templateName" size="40" value="${(template.name)?if_exists}" />		
		</td>
	</tr>
	<tr>
		<td class="textLabel">栏目logo<a href="#" onClick="BrowseServerImg('titleImg')">>></a>:</td>
		<td>
			<input type="text" class="divshow" name="titleImg" id="titleImg" size="40" value="${(titleImg)?if_exists}" />		
		</td>
	</tr>
	<tr>
		<td class="textLabel">文章模板</td>
		<td>
			<input type="hidden" name='contentTemplate.id' id="contentTemplateId" value="${(contentTemplate.id)?if_exists}"/>
			<input type="text" class='divshow' name="contentTemplate.name" id="contentTemplateName" size="40" value="${(contentTemplate.name)?if_exists}" />		
		</td>
	</tr>
	<tr>
		<td class="textLabel">特殊字段模板</td>
		<td>
			<input type="hidden" name='pertainTemplate.id' id="pertainTemplateId" value="${(pertainTemplate.id)?if_exists}"/>
			<input type="text" class='divshow' name="pertainTemplate.name" id="pertainTemplateName" size="40" value="${(pertainTemplate.name)?if_exists}" />		
		</td>
	</tr>
	<tr>
		<td class="textLabel">附带模板:</td>
		<td>
			<div style="word-break:break-all; " class="divShow">
				<@ftlMacro.checkboxDataSource name="otherTemplateIds" textValues=templates checkedValues=checkedOtherTemplateIdsList?if_exists/>
			</div>
		</td>
	</tr>
	<tr>
		<@ftlMacro.controlFck name="content" textShow="${content?if_exists}" colspan="2"/>
	</tr>
	<tr>
		<@ftlMacro.inputText name="keywords" descript="关键字" textShow="${keywords?if_exists}" cssStyle="required"/>
	</tr>
	<tr>
        <td class="textLabel"><div class='descript' >描述：</div>
        </td>
        <td class="textShow">
           <textarea name="description" class="textareaShow">${(description)?if_exists}</textarea>
        </td>
	</tr>
	<#if createUser?exists>
	<tr>
		<@ftlMacro.detailText descript="创建人" textShow="${createUser.name?if_exists}"/>
	</tr>
	</#if>
	<#if modifyUser?exists>
	<tr>
		<@ftlMacro.detailText descript="修改人" textShow="${modifyUser.name?if_exists}"/>
	</tr>
	</#if>
	<#if createTime?exists>
	<tr>
		<@ftlMacro.detailText descript="创建时间" textShow="${createTime?if_exists}"/>
	</tr>
	</#if>
	<#if modifyTime?exists>
	<tr>
		<@ftlMacro.detailText descript="修改时间" textShow="${modifyTime?if_exists}"/>
	</tr>
	</#if>
	<tr class="button">
		<td colspan="2">
			<input type="submit" value="提交" />&nbsp; 
			<input type="button" value="取消" onclick="history.back()"/>
		</td>
	</tr>
	<tr>
		<td colspan="2">
		</td>
	</tr>
</table>
</form>
</div>
</body>
</html>